From: | Gunther Nikl |
Date: | 12 Sep 2001 at 15:57:34 |
Subject: | [amiga-c] Re: VB int problem (was Re: Help needed with random crashing problem) |
Hello Paul,
> > Same here and it should be local to your interrupt function.
>
> If it's local won't the interrupt code have to put it on the stack or
> something?
If your function is simple the compiler will put local variables into
registers. The compiler does only use stackslots if there aren't enough
free registers.
> > db but pay attention to alignment issues. 32bit quantities are best
> > alignet at 32bit. If you use smaller types you should group them to
> > together to always get a multiple of 4. Use padding if that the only
> > way to achieve the alignment.
>
> I did think of doing that, but for some reason didn't. I did it for my
> MHI interrupt, as I think I said, although it probably wouldn't make
> much difference since everything here as the compiler uses absolute
> addressing anyway.
But your interrupt function is a critical part. You should always try
to be as fast as possible. If you can avoid absolute addressing you
should do. It doesn't matter what the rest of your program does.
> You make some good points. I didn't really think about using floating
> point code, but now it's clear it could cause problems. Removing the
> floating point code from the interrupt seems to have fixed the problem,
> the program is no longer crashing.
If its now solved than I think its very clear that you trashed the FPU
registers.
> It seems that there is a bit of an oversight in the RKMs then, regarding
> floating point register use.
Well, they were written then the presence of a FPU wasn't that commom.
Besides, this information is there since the RKMs tell you which registers
you may safely use. FPU registers are not mentioned .-)
> > You should replace your calculation with: tempvol = (mojo * 8) / 10;
> > BTW, no need to use shifts. Your compiler should know best when to
> > use which instructions.
>
> It does seem to have optimised the mulu.w #8,d0 into a rol.w #3,d0.
IMHO, the usage of rol.w seems to be a bug. After further thinking, I
would suggest that you replace the calculation with something like
that:
tempvol = (mojo * 51) / 64;
since this avoids the division. It 51/64 should be close enough to 0.8.
> does GNU C pick up on that kind of thing?
Yes, it does.
> However, I just realised the obvious mistake we both made. It's
> impossible to use the CIA timer,
I wasn't talking about CIA timers but about timer.device.
> and in fact better to use the VERTB timer which is based on the screen
> update. In order to use the analogue joystick registers (which is what
> the interrupt does, as you can see), you have to access the potgo
> register during the vertical blanking period, then read it again at
> the next vblank.
I am not an expert with hardware-banging. I hope you know what you do ;-)
Gunther
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Secure your servers with 128-bit SSL encryption! Grab your copy of VeriSign's FREE Guide: "Securing Your Web Site for Business." Get it Now!
http://us.click.yahoo.com/n7RbFC/zhwCAA/yigFAA/dpFolB/TM
---------------------------------------------------------------------~->
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/